package com.example.wechat;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.util.Log;

public class MyService1 extends Service {
    MediaPlayer player;
    int[] musics={
            R.raw.music1,
            R.raw.music2,
            R.raw.music3
    };
    //收到短信开始放歌
    //重点是reciver
    public MyService1() {

    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d("jd","Myservice1:onCreate");
        player = MediaPlayer.create(this, musics[0]);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d("jd","Myservice1:onStartCommand");
        player.start();
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        player.stop();
        player.release();
        Log.d("jd","Myservice1:onDestroy");
        super.onDestroy();
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }
    //看生命周期

}